package com.cdn.client.controller;

import com.cdn.client.CdnNodesClientApplication;
import com.cdn.client.netty.client.NettyClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {

    @Resource
    private NettyClient nettyClient;

    @GetMapping("test")
    public String test() {
        try {

            // 获取已连接的 Channel 并发送消息
            nettyClient.getChannel().writeAndFlush("Hello Test");
            return "Message sent to server!";
        } catch (Exception e) {
            e.printStackTrace();
            return "Error occurred while sending message.";
        }
    }
}
